package cn.iocoder.yudao.module.system.dal.mysql.record;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.record.ApprovalRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.record.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 审核操作记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ApprovalRecordMapper extends BaseMapperX<ApprovalRecordDO> {

    default PageResult<ApprovalRecordDO> selectPage(ApprovalRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ApprovalRecordDO>()
                .eqIfPresent(ApprovalRecordDO::getApplicationId, reqVO.getApplicationId())
                .eqIfPresent(ApprovalRecordDO::getCurrentNodeCode, reqVO.getCurrentNodeCode())
                .eqIfPresent(ApprovalRecordDO::getOperator, reqVO.getOperator())
                .eqIfPresent(ApprovalRecordDO::getOperationType, reqVO.getOperationType())
                .eqIfPresent(ApprovalRecordDO::getAuditResult, reqVO.getAuditResult())
                .eqIfPresent(ApprovalRecordDO::getCompleteStatus, reqVO.getCompleteStatus())
                .eqIfPresent(ApprovalRecordDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ApprovalRecordDO::getCompleteTime, reqVO.getCompleteTime())
                .eqIfPresent(ApprovalRecordDO::getAuditor, reqVO.getAuditor())
                .orderByDesc(ApprovalRecordDO::getId));
    }

    String getSourceDeptId(String catalogId);

    ApprovalRecordDO getRecordByApplicationIdAndNodeCode(@Param("applicationId") Integer applicationId, @Param("code") String code);

    List<ApprovalRecordDO> getRecordListByApplicationIdAndNodeCode(@Param("applicationId") Integer applicationId, @Param("code") String deptAudit);

    void deleteByApplicationIdAndCompleteStatus(@Param("applicationId") Integer applicationId);

    ApprovalRecordDO getAuditRecord(@Param("pageReqVO") ApprovalRecordPageReqVO pageReqVO);
}